
package com.scalar.chiptrack.operations.process.actions;


import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.scalar.chiptrack.ChipTrackAction;
import com.scalar.chiptrack.operations.process.dao.FabSubStage;
import com.scalar.chiptrack.operations.process.forms.FabSubStageForm;





public final class FabSubStageSaveAction extends ChipTrackAction {

    public FabSubStageSaveAction() {
    }

    public ActionForward execute (ActionMapping mapping, 
                                  ActionForm form, 
                                  HttpServletRequest request, 
                                  HttpServletResponse response) throws Exception {

			 HttpSession ses = request.getSession(true);

			 FabSubStageForm fabSubStageForm = (FabSubStageForm) form;
		
			 
					String fabStageId = request.getParameter("fabStageId");
					String [] fabStepName =fabSubStageForm.getFabStepName();
					//int [] procedureDoc = fabSubStageForm.getProcedureDoc();
					String [] comments = fabSubStageForm.getComments();

			 FabSubStage fabSubStage = null;
			 ArrayList fabSubStageList = new ArrayList();
			 	
            
			 for(int i=0;i<fabStepName.length;i++){
				if(!fabStepName.equals("")){
				fabSubStage=new FabSubStage();
				fabSubStage.setFabStepName(fabStepName[i]);
				//fabSubStage.setProcedureDoc(procedureDoc[i]);
				fabSubStage.setComments(comments[i]);
				fabSubStageList.add(fabSubStage);
				}
			 }
							

		
		
			ses.setAttribute(fabStageId,fabSubStageList);
			request.setAttribute("fabStageList",ses.getAttribute("fabStageList"));

			 return (mapping.findForward("success")); 
	}
	
}